﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kooboo.Domain;
using Kooboo.IoC;

namespace Kooboo.Commerce.Domain.Services
{
    public class PromotionLogService:ServiceBase<IPromotionLogRepository,IPromotionLog>
    {
        //internal PromotionLogService()
        //{
        //}

        public override IQueryable<IPromotionLog> QueryService
        {
            get {
                return this.Repository.PromotionLogs;
            }

        }


   
        public void Post(IPromotionLog promotionLog)
        {
           
            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Post(promotionLog);


                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }

        public void Put(IPromotionLog promotionLog)
        {

            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Put(promotionLog);

                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }

        public void Delete(IPromotionLog promotionLog)
        {

            using (var transaction = ObjectContainer.CreateInstance<TransactionContext>())
            {
                try
                {
                    this.Repository.Delete(promotionLog);

                    transaction.Commit();
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

        }

    }

}
